$NOMOD51

STACK_START     EQU   0x1d80// 0x1a80          //default at 0x180-0x1c0

#include "AC309N.h"

                NAME    ?C_STARTUP

?DT?STARTUP     SEGMENT DATA //at  0
//	PUBLIC	callbak2
//	PUBLIC	callbak1
	PUBLIC  spbak
    PUBLIC  sphbak	 
		RSEG  ?DT?STARTUP
   // callbak1:   DS   1
   // callbak2:   DS   1
	spbak:      DS   1
	sphbak:     DS   1

?C_C51STARTUP   SEGMENT   CODE

														
             //   EXTRN CODE (clock_init)
                EXTRN CODE (?C_START)
                PUBLIC  ?C_STARTUP

                CSEG    AT      0x180
				 nop

?C_STARTUP:     LJMP    STARTUP1

                RSEG    ?C_C51STARTUP

STARTUP1:
////////////////////////////////////////
               
			///	nop 
			//	nop 
				MOV		DPCON ,#0x00 // MOV		DPCON, A
                //pop callbak1 
				//pop callbak2
				//pop spbak
				//pop sphbak
				//push callbak2 
				//push callbak1
				mov spbak ,SP
				mov sphbak ,SPH  
				
				MOV     SP,#low(STACK_START - 1)
				MOV     SPH,#high(STACK_START - 1)       

 //               CALL    clock_init
/*
				MOV		DPCON, #0x20		//DPTR0 AUTO DEC
			
			 MOV     DPTR,#0x37FF		//9k
XDATALOOP:
                CLR     A
      			MOVX    @DPTR,A

				MOV     A,DPL
				XRL     A,#0xFF
				JNZ     XDATALOOP
				MOV     A,DPH
				XRL     A,#0xFF
				JNZ     XDATALOOP
	   */
                CLR     A
			   
                MOV     PSW,A
//////////////////////////////////////////
        
	   		    
               

				//push callbak2 
				//push callbak1
			    //push sphbak
			    //push spbak 
                LCALL     ?C_START
				mov SPH ,sphbak
				mov SP  ,spbak 
				
				ret
                END
